/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package session;

import entities.Customers;
import entities.OderFood;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author TANGQUOCTUAN
 */
@Stateless
public class ShowAllOrder implements ShowAllOrderLocal {
    @PersistenceContext(unitName = "eProject_Tunga_Restaurant-ejbPU")
    private EntityManager em;

    public void persist(Object object) {
        em.persist(object);
    }

    public List<OderFood> getAllOrderFood(String customer){
        Customers customers = em.find(Customers.class, customer);
        List<OderFood> listO = new ArrayList<OderFood>();
        if(customer != null){
            listO = customers.getOderFoodList();
        }
        return listO;
    }

    public List<Customers> getAllAccountUser(String name) {
        Query q = em.createNamedQuery("Customers.findCustByID");
        q.setParameter("custID", name);
        return q.getResultList();
    }

        public List<OderFood> reportShowBookRoom(Date fromdate, Date todate) {
        List<OderFood> list = new ArrayList<OderFood>();
        Query r = em.createNamedQuery("OderFood.findReportOrder");
        r.setParameter("fromdate", fromdate);
        r.setParameter("todate", todate);
        return list = r.getResultList();
    }
}
